//https://blog.csdn.net/zl1zl2zl3/article/details/81357146
import { PureComponent } from 'react';
import {
    Row,
    Col,
    Form,
    Input,
    Button,
    Modal,
} from 'antd';

const FormItem = Form.Item;

//查看表单
@Form.create()
class ViewForm extends PureComponent {
    static defaultProps = {
        handleViewModalVisible: () => {},
    values: {},
};

constructor(props) {
    super(props);

    this.state = {
        formVals: {
            id: props.values.id,
            name: props.values.name,
            ename: props.values.ename,
            contextpath: props.values.contextpath,
            tableprefix: props.values.tableprefix,
            logo: props.values.logo,
            icon: props.values.icon,
            version: props.values.version,
            builddate: props.values.builddate,
            status: props.values.status,
            orderid: props.values.orderid,
            memo: props.values.memo,
        },
    };


}



renderContent = (formVals) => {
    const { form } = this.props;

    return (
        <Form  layout="vertical" hideRequiredMark>



                <Row gutter={{ md: 8, lg: 24, xl: 48 }}>


                    <Col  md={12} sm={24}>
		                    <FormItem  label="系统名称">
		                        {form.getFieldDecorator('name', {
		                        rules: [{ required: true, message: '请输入至少五个字符的系统名称！', min: 5 }],
		                        initialValue: formVals.name,
		                        })(<Input  readOnly placeholder="请输入" />)}
		                    </FormItem>
                    </Col>


                    <Col  md={12} sm={24}>
		                    <FormItem  label="英文名称">
		                        {form.getFieldDecorator('ename', {
		                        rules: [{ required: true, message: '请输入至少五个字符的英文名称！', min: 5 }],
		                        initialValue: formVals.ename,
		                        })(<Input  readOnly placeholder="请输入" />)}
		                    </FormItem>
                    </Col>

                </Row>


                <Row gutter={{ md: 8, lg: 24, xl: 48 }}>


                    <Col  md={12} sm={24}>
		                    <FormItem  label="系统标志">
		                        {form.getFieldDecorator('logo', {
		                        rules: [{ required: true, message: '请输入至少五个字符的系统标志！', min: 5 }],
		                        initialValue: formVals.logo,
		                        })(<Input  readOnly placeholder="请输入" />)}
		                    </FormItem>
                    </Col>


                    <Col  md={12} sm={24}>
		                    <FormItem  label="系统图标">
		                        {form.getFieldDecorator('icon', {
		                        rules: [{ required: true, message: '请输入至少五个字符的系统图标！', min: 5 }],
		                        initialValue: formVals.icon,
		                        })(<Input  readOnly placeholder="请输入" />)}
		                    </FormItem>
                    </Col>

                </Row>

                <Row gutter={{ md: 8, lg: 24, xl: 48 }}>

                    <Col  md={12} sm={24}>
		                    <FormItem  label="版本">
		                        {form.getFieldDecorator('version', {
		                        rules: [{ required: true, message: '请输入至少五个字符的版本！', min: 5 }],
		                        initialValue: formVals.version,
		                        })(<Input  readOnly placeholder="请输入" />)}
		                    </FormItem>
                    </Col>
                    
                    
                    <Col  md={12} sm={24}>
		                    <FormItem  label="排序">
		                        {form.getFieldDecorator('orderid', {
		                        rules: [{ required: true, message: '请输入至少五个字符的排序！', min: 5 }],
		                        initialValue: formVals.orderid,
		                        })(<Input  readOnly placeholder="请输入" />)}
		                    </FormItem>
                    </Col>


                </Row>

                <Row gutter={{ md: 8, lg: 24, xl: 48 }}>



                    <Col  md={12} sm={24}>
		                    <FormItem  label="状态">
		                        {form.getFieldDecorator('status', {
		                        rules: [{ required: true, message: '请输入至少五个字符的状态！', min: 5 }],
		                        initialValue: formVals.status,
		                        })(<Input  readOnly placeholder="请输入" />)}
		                    </FormItem>
                    </Col>

					
                    <Col  md={12} sm={24}>
		                    <FormItem  label="备注">
		                        {form.getFieldDecorator('memo', {
		                        rules: [{ required: true, message: '请输入至少五个字符的备注！', min: 5 }],
		                        initialValue: formVals.memo,
		                        })(<Input  readOnly placeholder="请输入" />)}
		                    </FormItem>
                    </Col>



                </Row>




    </Form>
);

};


render() {
    const { viewModalVisible, handleViewModalVisible, values } = this.props;

    return (
        <Modal
    width={800}
    height={800}
    bodyStyle={{ padding: '32px 40px 48px' }}
    destroyOnClose
    title="查看"
    visible={viewModalVisible}
    onCancel={() => handleViewModalVisible(false, values)}
    footer={<Button key="back" onClick = { () => handleViewModalVisible(false, values) }>取消</Button>}
>

    {this.renderContent(values)}
</Modal>
);
}

}

export default ViewForm;

